{% extends '::backend.html.twig' %}
{% block contenido %}
{% block documentReadyJavascript %}
    {{ parent() }}
    <script src="{{ asset('js/persona.js') }}" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            $('#dialog-cancelar').dialog({
                autoOpen:false
            });

        $("#btnCancelar").click(function(e) {
            e.preventDefault();
            $('#dialog-cancelar').dialog({
                resizable: false,
                height:140,
                width: 450,
                modal: true,
                autoOpen: true,
                buttons: {
                    "Aceptar": function() {
                        $( this ).dialog( "close" );
                        var route = '{{ path ("persona") }}';
                        window.location = route;
                    },
                    "Cancelar": function() {
                        $( this ).dialog( "close" );
                        }
                    }            
                });
            });
        });
    </script>
{% endblock documentReadyJavascript %}
<legend>Nueva Persona</legend>

<form class="form-horizontal"  action="{{ path('persona_create') }}" method="post" {{ form_enctype(form) }}>  
    {{ form_widget(form._token) }} 
    {% include 'BackendBundle:Default:flashAlerts.html.twig'%}
    <fieldset>      
        <div class="control-group">
            <label class="control-label required" >Dni</label>
            <div class="controls">
                {{ form_errors(form.dni) }}
                {{ form_widget(form.dni) }}
            </div>
        </div>
        <div class="control-group">
            <label class="control-label required" >Nombre</label>
            <div class="controls">
                {{ form_errors(form.nombre) }}
                {{ form_widget(form.nombre) }}
            </div>
        </div>
        <div class="control-group">
            <label class="control-label required">Apellido</label>
            <div class="controls">
                {{ form_errors(form.apellido) }}
                {{ form_widget(form.apellido) }}
            </div>
        </div>
        <div class="control-group">
            <label class="control-label required">Email</label>
            <div class="controls">
                {{ form_errors(form.email) }}
                {{ form_widget(form.email) }}
                </div>
        </div>
        <div class="control-group">
            <label class="control-label required">Tel&eacute;fono</label>
            <div class="controls">
                {{ form_errors(form.telefono) }}
                {{ form_widget(form.telefono) }}
            </div>
        </div>
        <div class="control-group">
            <label class="control-label required">Direcci&oacute;n</label>
            <div class="controls">
                {{ form_errors(form.direccion) }}
                {{ form_widget(form.direccion) }}
                </div>
        </div>
        <div class="control-group">
            <label class="control-label required">C&oacute;digo Postal</label>
                <div class="controls">
                    {{ form_errors(form.codigopostal) }}
                    {{ form_widget(form.codigopostal) }}
                </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn btn-success save">
                <i class="icon-ok icon-black"></i> Guardar
            </button>
            <a id="btnCancelar" class="btn btn-danger">
                <i class="icon-remove icon-black"></i> Cancelar
            </a>
        </div>
        <div id="dialog-cancelar" title="Confirmación">
            <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span> Est&aacute; por cancelar la operaci&oacute;n. ¿Est&aacute; seguro?</p>
        </div>
    </fieldset>
</form>
{% endblock %}

